package com.yjhb.android.sbz.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.tool.EventMsg;
import com.yjhb.android.sbz.tool.LoadingDialogTool;
import com.yjhb.android.sbz.tool.Tool;
import com.jojo.android.zxlib.base.mvp.BasePresenter;
import com.jojo.android.zxlib.view.dialog.ILoading;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * 创建者 zx
 * 创建时间 2020/11/24 11:50
 */
public abstract class BaseActivity<P extends BasePresenter> extends com.jojo.android.zxlib.base.BaseActivity<P> {
    private final String TAG = "BaseActivity";
    protected static final int RESULT_UPDATE = 2001;
    protected ILoading loadingDialog;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        loadingDialog = LoadingDialogTool.createDialog(this);
        EventBus.getDefault().register(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected boolean intercept() {
        if (isCheckLogin()){
            if (!Tool.checkLogin(this)){
                finish();
                return true;
            }
        }
        return super.intercept();
    }

    protected boolean isCheckLogin(){
        return false;
    }

    @Override
    protected void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMsg(EventMsg msg) {

    }


    @Override
    protected int getStatusBarResource() {
        return R.color.colorPrimaryDark;
    }

    @Override
    protected boolean isImmerse() {
        return true;
    }
}
